package com.sl.au.entity;

import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "sl_au_role")
public class Role extends Root {
	@Column(nullable = false)
	private String name;
	
	private String creator;
	
	private String description;
	
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "sl_au_m2r", joinColumns = @JoinColumn(name = "roleId", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "moduleId", referencedColumnName = "id") )
	@OrderBy("groupId asc,createTime asc")
	private List<Module> modules;

	@Transient
	private List<ModuleInfo> moduleInfos;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public List<Module> getModules() {
		return modules;
	}

	public void setModules(List<Module> modules) {
		this.modules = modules;
	}

	public List<ModuleInfo> getModuleInfos() {
		return moduleInfos;
	}

	public void setModuleInfos(List<ModuleInfo> moduleInfos) {
		this.moduleInfos = moduleInfos;
	}

}
